<?php
/**
 * This form is used to allow the user change their email address
*/
class forms_CreateUserForm extends Zend_Form
{
	/**
	 * Holds a reference to a validator object
	 *
	 * @var Validator 
	 */
	protected $Validator;
	
	
	/**
	 * Setup Form
	 * 
	 * @access public
	 */	
	public function init()
	{

		if(is_null($this->Validator)) {
			throw new Exception("You need to pass a validation context to this form");
		}
		
		$this->setAction('/index/createuser')
			 ->setMethod('post');

		/**
		 * Create the email address form field
		*/
		$summary = $this->addElement('text', 'email', array('label' => 'Email Address', 'size'=>'70'));
		$summary->getElement('email')
				->addValidator($this->Validator->newEmailAddress())
				->setRequired(true);
				
		/**
		 * create the nickname form field to update the user's profile
		 */
		$summary = $this->addElement('text', 'nickname', array('label' => 'Profile Nickname', 'size'=>'70'));
		$summary->getElement('nickname')
				->addValidator($this->Validator->Profile->getValidatorChain('nickname'));
					
		/**
		 * Add the submit button to the form
		*/
		$this->addElement('submit', 'Create New User', array('label' => 'Create New User'));

	}
	
	/**
	 * Allows a context to be set to be able to share the form validation and business logic validations
	 *
	 * @param Validator $validator
	 */
	public function setValidator(Validator $validator)
	{
		$this->Validator = $validator;
	}
}
?>